// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Mapping;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Mapping.Json.ChunkingSettingsConverter))]
public sealed partial class ChunkingSettings
{
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public ChunkingSettings(int maxChunkSize, string strategy)
	{
		MaxChunkSize = maxChunkSize;
		Strategy = strategy;
	}
#if NET7_0_OR_GREATER
	public ChunkingSettings()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	[System.Obsolete("The type contains required properties that must be initialized. Please use an alternative constructor to ensure all required values are properly set.")]
	public ChunkingSettings()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal ChunkingSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	/// <summary>
	/// <para>
	/// The maximum size of a chunk in words.
	/// This value cannot be lower than <c>20</c> (for <c>sentence</c> strategy) or <c>10</c> (for <c>word</c> strategy).
	/// This value should not exceed the window size for the associated model.
	/// </para>
	/// </summary>
	public
#if NET7_0_OR_GREATER
	required
#endif
	int MaxChunkSize { get; set; }

	/// <summary>
	/// <para>
	/// The number of overlapping words for chunks.
	/// It is applicable only to a <c>word</c> chunking strategy.
	/// This value cannot be higher than half the <c>max_chunk_size</c> value.
	/// </para>
	/// </summary>
	public int? Overlap { get; set; }

	/// <summary>
	/// <para>
	/// The number of overlapping sentences for chunks.
	/// It is applicable only for a <c>sentence</c> chunking strategy.
	/// It can be either <c>1</c> or <c>0</c>.
	/// </para>
	/// </summary>
	public int? SentenceOverlap { get; set; }

	/// <summary>
	/// <para>
	/// Only applicable to the <c>recursive</c> strategy and required when using it.
	/// </para>
	/// <para>
	/// Sets a predefined list of separators in the saved chunking settings based on the selected text type.
	/// Values can be <c>markdown</c> or <c>plaintext</c>.
	/// </para>
	/// <para>
	/// Using this parameter is an alternative to manually specifying a custom <c>separators</c> list.
	/// </para>
	/// </summary>
	public string? SeparatorGroup { get; set; }

	/// <summary>
	/// <para>
	/// Only applicable to the <c>recursive</c> strategy and required when using it.
	/// </para>
	/// <para>
	/// A list of strings used as possible split points when chunking text.
	/// </para>
	/// <para>
	/// Each string can be a plain string or a regular expression (regex) pattern.
	/// The system tries each separator in order to split the text, starting from the first item in the list.
	/// </para>
	/// <para>
	/// After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
	/// the <c>max_chunk_size</c> limit, to reduce the total number of chunks generated.
	/// </para>
	/// </summary>
	public System.Collections.Generic.ICollection<string>? Separators { get; set; }

	/// <summary>
	/// <para>
	/// The chunking strategy: <c>sentence</c>, <c>word</c>, <c>none</c> or <c>recursive</c>.
	/// </para>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// If <c>strategy</c> is set to <c>recursive</c>, you must also specify:
	/// </para>
	/// </item>
	/// </list>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// <c>max_chunk_size</c>
	/// </para>
	/// </item>
	/// <item>
	/// <para>
	/// either <c>separators</c> or<c>separator_group</c>
	/// </para>
	/// </item>
	/// </list>
	/// <para>
	/// Learn more about different chunking strategies in the linked documentation.
	/// </para>
	/// </summary>
	public
#if NET7_0_OR_GREATER
	required
#endif
	string Strategy { get; set; }
}

public readonly partial struct ChunkingSettingsDescriptor
{
	internal Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public ChunkingSettingsDescriptor(Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public ChunkingSettingsDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor(Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings instance) => new Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings(Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// The maximum size of a chunk in words.
	/// This value cannot be lower than <c>20</c> (for <c>sentence</c> strategy) or <c>10</c> (for <c>word</c> strategy).
	/// This value should not exceed the window size for the associated model.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor MaxChunkSize(int value)
	{
		Instance.MaxChunkSize = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The number of overlapping words for chunks.
	/// It is applicable only to a <c>word</c> chunking strategy.
	/// This value cannot be higher than half the <c>max_chunk_size</c> value.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor Overlap(int? value)
	{
		Instance.Overlap = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The number of overlapping sentences for chunks.
	/// It is applicable only for a <c>sentence</c> chunking strategy.
	/// It can be either <c>1</c> or <c>0</c>.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor SentenceOverlap(int? value)
	{
		Instance.SentenceOverlap = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Only applicable to the <c>recursive</c> strategy and required when using it.
	/// </para>
	/// <para>
	/// Sets a predefined list of separators in the saved chunking settings based on the selected text type.
	/// Values can be <c>markdown</c> or <c>plaintext</c>.
	/// </para>
	/// <para>
	/// Using this parameter is an alternative to manually specifying a custom <c>separators</c> list.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor SeparatorGroup(string? value)
	{
		Instance.SeparatorGroup = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Only applicable to the <c>recursive</c> strategy and required when using it.
	/// </para>
	/// <para>
	/// A list of strings used as possible split points when chunking text.
	/// </para>
	/// <para>
	/// Each string can be a plain string or a regular expression (regex) pattern.
	/// The system tries each separator in order to split the text, starting from the first item in the list.
	/// </para>
	/// <para>
	/// After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
	/// the <c>max_chunk_size</c> limit, to reduce the total number of chunks generated.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor Separators(System.Collections.Generic.ICollection<string>? value)
	{
		Instance.Separators = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Only applicable to the <c>recursive</c> strategy and required when using it.
	/// </para>
	/// <para>
	/// A list of strings used as possible split points when chunking text.
	/// </para>
	/// <para>
	/// Each string can be a plain string or a regular expression (regex) pattern.
	/// The system tries each separator in order to split the text, starting from the first item in the list.
	/// </para>
	/// <para>
	/// After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
	/// the <c>max_chunk_size</c> limit, to reduce the total number of chunks generated.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor Separators(params string[] values)
	{
		Instance.Separators = [.. values];
		return this;
	}

	/// <summary>
	/// <para>
	/// The chunking strategy: <c>sentence</c>, <c>word</c>, <c>none</c> or <c>recursive</c>.
	/// </para>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// If <c>strategy</c> is set to <c>recursive</c>, you must also specify:
	/// </para>
	/// </item>
	/// </list>
	/// <list type="bullet">
	/// <item>
	/// <para>
	/// <c>max_chunk_size</c>
	/// </para>
	/// </item>
	/// <item>
	/// <para>
	/// either <c>separators</c> or<c>separator_group</c>
	/// </para>
	/// </item>
	/// </list>
	/// <para>
	/// Learn more about different chunking strategies in the linked documentation.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor Strategy(string value)
	{
		Instance.Strategy = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings Build(System.Action<Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor> action)
	{
		var builder = new Elastic.Clients.Elasticsearch.Mapping.ChunkingSettingsDescriptor(new Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}